﻿//remove special characters from string
function removeSpecialChars(strVal){
    strVal = strVal.replace(/\/+/g, ' ');
    return $.trim(strVal);
}

//validate input value of address textbox
function validateAddress() {
    var currCity = $("#city").val(); //save current city when page reload
    $("#currCity_1").val(currCity);
    var address = $("#txtAddress").val(); //Lay gia tri address nhap vao
    if ($.trim(address) == "" || address == $("#txtAddress").attr("title")) {
        createQtip("#txtAddress", "Bạn chưa nhập thông tin !", 190, -200, 0); //show qtip
        return false;
    }
    return true;
}

//validate input value of start location textbox
function validateStartLocation() {
    var start_location = $("#start_location").val(); //Lay gia tri address nhap vao
    if ($.trim(start_location) == "" || start_location == $("#start_location").attr("title")) {
        createQtip("#start_location", "Bạn chưa nhập thông tin !", 190, -200, 0); //show qtip
        return false;
    }
    return true;
}

//validate input value of end location textbox
function validateEndLocation() {
    var end_location = $("#end_location").val(); //Lay gia tri address nhap vao
    if ($.trim(end_location) == "" || end_location == $("#end_location").attr("title")) {
        createQtip("#end_location", "Bạn chưa nhập thông tin !", 190, -200, 0); //show qtip
        return false;
    }
    return true;
}

function validateSE(){
    var currCity = $("#city").val(); //save current city when page reload
    $("#currCity_2").val(currCity);
    return validateStartLocation() && validateEndLocation();
}

function openFancybox() {
    $.fancybox({
        'autoScale': true,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'href': '#inline1',
        'titleShow': false,
        'padding': 0,
        'scrolling': 'no'
    });
}